﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>微信公众号管理</title>
	<link rel="stylesheet" href="css/common2.css">

	<style>
		.one {
			width: 9%;
		}

		.four {
			width: 20%;
		}

		label.add {
			background-image: url(image/add_time.png) !important;
			margin: 0;
			padding: 0;
			width: 140px;
			background-size: 140px 35px;
		}

		.action-buttons:nth-child(1) {
			margin-left: 2%;
		}
	</style>
</head>

<body class="main-body">
	<div id="vue-root" style="margin-top: 50px;">
		<form enctype="multipart/form-data" id="form" ref="form" style="display: none;">
			<input type="file" name="file" id="file" ref="file" accept="text/plain" @change="upload">
		</form>
		<div>
			<template v-if="able.add">
			<div class="add action-buttons" style="background-size:120px 35px;" >
				<a href="wechat_platform_item.html" style="color: white">添加公众号</a>
			</div>
			<label class="add action-buttons" for="file" style="margin: 0 10px;">上传域名验证文件</label>
			</template>
			<div class="refresh action-buttons" onclick="location.reload()">刷新</div>
			<input class="search" placeholder="请输入名称" v-model="search.name"
				style="position: absolute; right: 100px; height: 33px; max-width: 118px;">
			<img src="../image/search.png" height="35" width="35" class="search_img"
				style="position: absolute; right: 3%;" @click="getData0">

			<br>
			<div class="table">
				<table class="table_top">
					<thead>
						<tr>
							<th class="two">
								<input type="checkbox" class="check-box" v-model="all">
							</th>
							<th>序号</th>
							<th>公众号名称</th>
							<th>创建时间</th>
							<th>到期时间</th>
							<th>用户绑定链接</th>
							<th>家长中心链接</th>
							<th>教师中心链接</th>
							<th>消息模板</th>
							<th class="three" v-if="able.edit||able.del">编辑/删除</th>
						</tr>
					</thead>
					<tbody id="list">
						<tr v-for="(wechatPlatform,index) in list" :key="wechatPlatform.id">
							<td>
								<input type="checkbox" class="check-box" v-model="wechatPlatform.checked">

							</td>
							<td><span v-text="index+1"></span></td>
							<td class="four" v-text="wechatPlatform.name"></td>
							<td v-text="createTime(wechatPlatform.id)"></td>
							<td v-text="wechatPlatform.expiryDate"></td>
							<td>
								<button class="btn" :data-clipboard-text="wechatPlatform.indexLink">复制</button>
							</td>
							<td>
								<button class="btn" :data-clipboard-text="wechatPlatform.studentLink">复制</button>
							</td>
							<td>
								<button class="btn" :data-clipboard-text="wechatPlatform.teacherLink">复制</button>
							</td>
							<td>
								<template v-if="wechatPlatform.templateApplied">已设置</template>
								<button v-else @click="tpls(wechatPlatform.id)">设置</button>
							</td>
							<td class="three" v-if="able.edit||able.del">
								<div class="option">
									<div v-if="able.edit" class="edit-icon option-icon">
										<a :href="'wechat_platform_item.html?id='+wechatPlatform.id"
											style="position: absolute; left: 20%; top: 30%;">
											<img class="img" src="../image/edit.png" height="20" width="20"
												onmouseover="this.src='image/edit_light.png'"
												onmouseout="this.src='image/edit.png'" />
										</a>
									</div>
									<div v-if="able.del" class="delete-icon option-icon"
										@click="del([wechatPlatform.id])"
										style="right: 20%; top:30%;position: absolute;">
										<img class="img" src="../image/delete.png" height="20" width="20"
											onmouseover="this.src='image/delete_light.png'"
											onmouseout="this.src='image/delete.png'" />
									</div>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="delete" @click="batchDelete" v-if="able.del||total>1">批量删除</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
			<li>
				<a v-text="pages"></a>
				<!--页面总数-->
			</li>
		</ul>
		<div style="float: right;margin-bottom: 20px;" v-if="pages>1">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<!--style="margin-top: 14px;"-->
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/clipboard.min.js"></script>
	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>

		var app = new Vue(merge({
			data: {
				urls: {
					del: '/pc/wechatPlatform/del',
					list: '/pc/wechatPlatform/list'
				}
			},
			created: function () {
				if (/agent/.test(top.location.href))
					this.search.agentId = top_params().id;

				this.getData();
				abled('platform', this);
			},
			methods: {
				tpls: function (id) {
					axios.post('/pc/wechatPlatform/tpl/' + id).then(function (res) {
						alert('设置成功');
						location.reload();
					});
				},
				upload: function () {
					axios.post('/pc/wechatPlatform/upload', new FormData(this.$refs.form)).then(function () {
						alert('成功');
					}.bind(this)).catch(function () {
						this.$refs.file.value = '';
					}.bind(this));
				},
				createTime: function (id) {
					return dayjs(id / 4096 + 1.56E12).format('YYYY-MM-DD');
				}
			},
			watch: {
				list: function (newValue, oldValue) {
					this.$nextTick(function () {
						new ClipboardJS('.btn');
					});
				}
			}
		}));
	</script>

</body>

</html>